#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>

#include <iostream>
#include <thread>
#include "NodeHost.h"
#include "NodeCCD.h"

int main(int argc,char *argv[])
{
    int ret = 0;
#if 1
	NodeHost *thisHost = NodeHost::getHost();
	std::cout << "Host Name:" << thisHost->name() << std::endl;

	thisHost->initEnv();
	std::cout << "Host init env: " << true << std::endl;

	thisHost->startService();
	std::cout << "Host start service end!" << std::endl;

	NodeCCD *thisCCD = NodeCCD::getCCD();
	std::cout << "CCD Name:Raspi" << std::endl;

	thisCCD->initEnv("192.168.0.115",8888);
	std::cout << "CCD Cloud : 192.168.0.115:8888" << std::endl;

	thisCCD->begin();
	std::cout << "CCD start service end!" << std::endl;

	DateTime dt;
	NodeAppBoard boards[9];
	while(true)
	{
		dt = thisHost->getTime();
		std::cout << "Host now: " << dt << ",boards num:" << thisHost->getAppBoard(boards) << std::endl;

		std::this_thread::sleep_for(std::chrono::seconds(10));
	}
#else // x86 Debug 
	NodeCCD *thisCCD = NodeCCD::getCCD();
	std::cout << "CCD Name:Raspi" << std::endl;

	thisCCD->initEnv("192.168.0.115",8888);
	std::cout << "CCD Cloud : 192.168.0.115:8888" << std::endl;

	thisCCD->begin();
	std::cout << "CCD start service end!" << std::endl;

	while(true)
	{
		std::this_thread::sleep_for(std::chrono::seconds(10));
	}
#endif

    return ret;
}
